<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>Demo</title>
    <meta name="description" content=""/>
    <meta name="viewport" content="width=device-width"/>
    <base href="/"/>
</head>
<body>

<div id="message"></div>

<script src="/webjars/jquery/jquery.min.js"></script>
<script>

    // <1>
    var greetingsClientUrl = location.protocol + "//" + window.location.host
        + "/greetings-client-uri";
    $.ajax({url: greetingsClientUrl}).done(function (data) {
        var nameToGreet = window.prompt("who would you like to greet?");
        var greetingsServiceUrl = data['uri'] + "/lets/greet/" + nameToGreet;
        console.log('greetingsServiceUrl: ' + greetingsServiceUrl);
        // <2>
        $.ajax({url: greetingsServiceUrl}).done(function (greeting) {
            $("#message").html(greeting['greeting']);
        });
    });
</script>
</body>
</html>